#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> indexes(n);
  vector<long long> sum(n);
  for (int index = 1; index <= m; index++) {
    int t;
    cin >> t;
    int candidate = 0;
    for (int i = 1; i < n; i++) {
      if (sum[i] < sum[candidate]) {
        candidate = i;
      }
    }
    sum[candidate] += t;
    indexes[candidate].push_back(index);
  }
  for (auto& line : indexes) {
    if (line.size() == 0) {
      cout << 0 << endl;
    } else {
      for (auto& index : line) {
        cout << index << ' ';
      }
      cout << endl;
    }
  }
}